package com.ln.lnzw.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.ln.lnzw.R;
import com.ln.lnzw.adapter.NewsFragmentPagerAdapter;
import com.ln.lnzw.base.BaseActivity;
import com.ln.lnzw.fragment.LegalPersonLoginFragment;
import com.ln.lnzw.fragment.NaturalPersonLoginFragment;
import com.ln.lnzw.utils.CacheActivity;
import com.ln.lnzw.view.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wuwei on 2018/3/30.
 * 登录页面
 */

public class LoginActivity extends BaseActivity {
    @BindView(R.id.SlidingTabLayout)
    com.flyco.tablayout.SlidingTabLayout SlidingTabLayout;
    @BindView(R.id.viewpager)
    NoScrollViewPager viewpager;
    private List<Fragment> fragmentList;
    private List<String> nameFragment;
    private NewsFragmentPagerAdapter mAdapetr;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_registered);
        ButterKnife.bind(this);
//        CacheActivity.addActivity(activity);
        initData();
        initView();
    }

    private void initData() {
        nameFragment = new ArrayList<>();
        fragmentList = new ArrayList<>();
        nameFragment.add("自然人登录");
        nameFragment.add("法人登录");
        NaturalPersonLoginFragment naturalPersonLoginFragment = new NaturalPersonLoginFragment();
        LegalPersonLoginFragment legalPersonLoginFragment = new LegalPersonLoginFragment();
        fragmentList.add(naturalPersonLoginFragment);
        fragmentList.add(legalPersonLoginFragment);
    }

    private void initView() {
        mAdapetr = new NewsFragmentPagerAdapter(activity.getSupportFragmentManager(), fragmentList, nameFragment);
        viewpager.setAdapter(mAdapetr);
        viewpager.setOffscreenPageLimit(2);
        viewpager.setCurrentItem(0, false);
        SlidingTabLayout.setViewPager(viewpager);

    }

    @OnClick(R.id.iv_back)
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
